
/*
 * Copyright (c) 2021. Dylan Cai
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@file:Suppress("unused")

//package com.dylanc.longan
package com.gitee.wsl.ext.string

import com.gitee.wsl.ext.array.hashHmacSHA1toString
import com.gitee.wsl.ext.array.hashHmacSHA256toString
import com.gitee.wsl.ext.array.hashHmacSHA512toString
import com.gitee.wsl.ext.array.hashHmacSM3toString
import com.gitee.wsl.ext.array.hashMD4toString
import com.gitee.wsl.ext.array.hashMD5toString
import com.gitee.wsl.ext.array.hashSHA1toString
import com.gitee.wsl.ext.array.hashSHA256toString
import com.gitee.wsl.ext.array.hashSHA512toString
import com.gitee.wsl.ext.array.hashSM3toString


//fun String.encodeUtf8() = encodeToByteArray().toByteString()
fun String.encryptSM3(): String = encodeToByteArray().hashSM3toString()

fun String.encryptHmacSM3(key: String): String = encodeToByteArray().hashHmacSM3toString(key)

fun String.encryptMD4(): String = encodeToByteArray().hashMD4toString()
fun String.encryptMD5(): String = encodeToByteArray().hashMD5toString()

fun String.encryptSHA1(): String = encodeToByteArray().hashSHA1toString()

fun String.encryptSHA256(): String = encodeToByteArray().hashSHA256toString()

fun String.encryptSHA512(): String = encodeToByteArray().hashSHA512toString()

fun String.encryptHmacSHA1(key: String): String = encodeToByteArray().hashHmacSHA1toString(key)

fun String.encryptHmacSHA256(key: String): String = encodeToByteArray().hashHmacSHA256toString(key)

fun String.encryptHmacSHA512(key: String): String = encodeToByteArray().hashHmacSHA512toString(key)

